<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="https://lf3-cdn-tos.bytecdntp.com/cdn/expire-1-M/vue/2.6.14/vue.js" type="application/javascript"></script>
</head>
<body>
  <div id="app">
    {{msg}}
    <!-- 父组件 监听方式1  -->
    <el-button @click="onClick"></el-button>
    <!-- 监听方式2 原生事件冒泡 -->
    <el-button @click.native="onClick"></el-button>
  </div>
</body>
<script>
  Vue.component('el-button',{
    // 子组件 监听方式1 
    template:`
    <button @click="$emit('click')">按钮</button>
    `
  })
  let vm = new Vue({
    el: '#app',
    data(){
      return {
        msg: 'hello'
      }
    },
    methods: {
      onClick () {
        console.log('点击了')
      }
    },
  })
</script>
</html>
